Skip to content

fix(tls): enforce signature provider contracts - #11

Merged
thieman merged 8 commits into
mainfrom
thieman/fix-provider-contract-hardening
Jun 24, 2026
Merged

fix(tls): enforce signature provider contracts#11
thieman merged 8 commits into
mainfrom
thieman/fix-provider-contract-hardening

Conversation

@thieman

@thieman thieman commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #8, narrowed to the minimal provider-contract changes:

  • Enforce rustls/webpki-style RSA verification modulus bounds (2048-8192 bits) before CNG public-key import.
  • Add RSA PKCS#1 SHA-256/SHA-384/SHA-512 certificate verification AlgorithmIdentifier variants for absent parameters.
  • Stop advertising unsupported Ed25519 in TLS 1.2 ECDSA cipher-suite signing schemes.

The broader hardening items from #8 (AEAD in-place aliasing strategy, private-key import zeroization, TLS 1.2 oversized plaintext handling, and runtime panic cleanup) are intentionally deferred for smaller follow-up PRs with focused review.

Testing

Local macOS validation:

  • cargo fmt -- --check
  • cargo check --target x86_64-pc-windows-msvc
  • cargo clippy --target x86_64-pc-windows-msvc -- -D warnings
  • git diff --check

Windows runtime validation is expected from GitHub Actions.

Notes for reviewers

This PR now changes only src/verify.rs and src/tls12.rs relative to main.

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jun 23, 2026

Copy link
Copy Markdown

Code Quality  Code Vulnerabilities

🎉 All green!

🛠️ No new code quality issues
🛡️ No new code vulnerabilities

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ecc0b81 | Docs | Datadog PR Page | Give us feedback!

Comment thread src/verify.rs Outdated
Comment thread src/verify.rs Outdated
Comment thread src/verify.rs Outdated
@thieman thieman changed the title Harden rustls provider contract enforcement fix(tls): harden provider contract enforcement Jun 23, 2026
@thieman thieman changed the title fix(tls): harden provider contract enforcement fix(tls): enforce signature provider contracts Jun 23, 2026
Comment thread src/tls12.rs Outdated
#[test]
fn tls12_ecdsa_sign_schemes_do_not_advertise_ed25519() {
assert!(!ECDSA_SCHEMES.contains(&SignatureScheme::ED25519));
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is pointless, remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Removed the test in 094eead.

@thieman
thieman marked this pull request as ready for review June 23, 2026 18:41
@thieman
thieman requested a review from a team as a code owner June 23, 2026 18:41
Comment thread src/tls12.rs
const GCM_IMPLICIT_NONCE_LENGTH: usize = 4;

static ECDSA_SCHEMES: &[SignatureScheme] = &[
SignatureScheme::ED25519,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not actually supported, and GPT claims that's fine from a FIPS perspective. This removal stops advertising it as supported.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, yeah, like this actually seems bad... like fundamentally not possible since the whole thing is that ED25519 is a different scheme from ECDSA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Evaluated against the current provider: Ed25519 is widely used, but this CNG-backed provider does not implement Ed25519 signing or verification (src/signer/ec.rs explicitly notes CNG does not support it here, and src/verify.rs has Ed25519 commented out). So I kept the removal from the TLS 1.2 ECDSA scheme list; advertising it would imply a capability the provider cannot satisfy.

Comment thread src/verify.rs
Comment on lines +254 to +255
const RSA_MIN_MODULUS_BITS: usize = 2048;
const RSA_MAX_MODULUS_BITS: usize = 8192;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have the agent try and provide first-party documentation sources for stuff like this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Added a source note in cddb6ca. The first-party source I used is rustls-webpki itself: its RSA verification algorithms are named/defined for 2048-8192-bit keys, e.g. RSA_PKCS1_2048_8192_SHA256 and the matching PSS variants in rustls-webpki-0.103.13/src/ring_algs.rs / aws_lc_rs_algs.rs. This provider now mirrors that policy before passing RSA public keys to CNG.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Updated in d132442 to include a direct source link in the code comment. It now points at rustls-webpki 0.103.13’s first-party RSA verification algorithm definitions for 2048-8192-bit keys: https://docs.rs/rustls-webpki/0.103.13/src/rustls_webpki/aws_lc_rs_algs.rs.html#162-182

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took three tries, but it got there.

Comment thread src/verify.rs Outdated
RSA_PSS_SHA512,
RSA_PSS_SHA384,
RSA_PSS_SHA256,
// RFC 4055 requires accepting sha*WithRSAEncryption AlgorithmIdentifiers both with

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar-ish content about linking to first-party sources... maybe the specific section in the RFC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Added a more specific source note in cddb6ca. RFC 4055 section 2.1 says implementations MUST accept both NULL and absent parameters as legal/equivalent encodings for these hash AlgorithmIdentifiers. rustls-webpki also registers both present-parameter and _ABSENT_PARAMS RSA PKCS#1 variants, so this mirrors the built-in provider behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GPT 5.5] Updated in d132442 to include direct links in the code comment: RFC 4055 section 2.1 for accepting NULL and absent parameters (https://www.rfc-editor.org/rfc/rfc4055.html#section-2.1), plus rustls-webpki’s _ABSENT_PARAMS algorithms (https://docs.rs/rustls-webpki/0.103.13/src/rustls_webpki/aws_lc_rs_algs.rs.html#186-245).

@thieman
thieman merged commit f03b200 into main Jun 24, 2026
10 checks passed
@thieman
thieman deleted the thieman/fix-provider-contract-hardening branch June 24, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce rustls provider contracts and security hardening

2 participants